<%--
  Created by IntelliJ IDEA.
  User: xiaoyou
  Date: 2021/12/1
  Time: 9:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="<%=request.getContextPath()+"/"%>"/>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
         $(function () {
              $("#sub").click(function () {
                   //发送ajax请求进行数据添加
                  $.post("BookServlet?method=save",$("#fm1").serialize(),function (rs) {
                          if(rs>0){
                              //添加成功
                              window.location.href="show.jsp";
                          }else{
                              alert("添加失败！！")
                          }
                  },"json")

              })
         })
    </script>
</head>
<body>
    <form id="fm1">
         <p>
             图书名称:<input type="text" name="bname"/>
         </p>
        <p>
            图书价格:<input type="text" name="bprice"/>
        </p>
        <p>
            出版日期:<input type="text" name="dtdate"/>
        </p>
        <p>
            出版社:<input type="text" name="prod"/>
        </p>
        <p>
            <input type="button" value="提交" id="sub"/>
        </p>
    </form>
</body>
</html>
